package com.zdpx.pxframework.log;

import com.zdpx.pxframework.log.aop.OperateLogAspect;
import com.zdpx.pxframework.log.properties.LoggingProperties;
import com.zdpx.pxframework.log.service.OperateLogFrameworkService;
import com.zdpx.pxframework.log.service.impl.OperateLogFrameworkServiceImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * 日志自动配置类
 *
 * @Description:
 * @Author: Cheng XiaoXiao
 * @Date: 2022/5/23 11:29
 */
@EnableAsync
@Configuration
@ConditionalOnWebApplication
@EnableConfigurationProperties(LoggingProperties.class)
public class LogAutoConfiguration {
    @Bean
    public OperateLogAspect operateLogAspect(){
        return new OperateLogAspect();
    }

    @Bean
    @ConditionalOnMissingBean
    public OperateLogFrameworkService operateLogFrameworkService(){
        return new OperateLogFrameworkServiceImpl();
    }
}
